home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Development Kits / MPW etc / MPW-PR / Interfaces&Libraries / Interfaces / CIncludes / stdarg.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-06-11  |  1.6 KB  |  52 lines  |  [TEXT/MPS ]

  1. /*
  2.     StdArg.h -- Variable arguments
  3.     
  4.     Copyright Apple Computer,Inc.    1987, 1990, 1994-1998
  5.     All rights reserved.
  6.  
  7. */
  8.  
  9.  
  10. #ifndef __STDARG__
  11. #define __STDARG__
  12.  
  13. /*
  14.  * Get common declarations 
  15.  */
  16.  
  17. #include <NullDef.h>
  18. #include <SizeTDef.h>
  19. #include <VaListTDef.h>
  20.  
  21. #if __spillargs
  22.     /*    "__spillargs" needed for MrC[pp] PowerMac register-based calling conventions.*/
  23.     /*    When using other preprocessors other than MrC, simply define "__spillargs".  */
  24.     #undef __spillargs
  25.     extern int __spillargs;
  26.     #define va_start(ap, parmN) ap = (__spillargs, (va_list)((unsigned int)&(parmN) + (((sizeof(parmN)+3)/4)*4)))
  27.  
  28. #elif !defined (__SC__) || defined (__CFM68K__)
  29.     /*    most normal compilers are long-word aligned…  */
  30.     #define va_start(ap, parmN) ap = (va_list)((unsigned int)&(parmN) + (((sizeof(parmN)+3)/4)*4))
  31.  
  32. #else
  33.     /*    …but Symantec C is word aligned.  */
  34.     #define va_start(ap, parmN) ap = (va_list)((char*)&parmN + (((sizeof(parmN)+1)/2)*2))
  35. #endif
  36.     
  37.     /* Vector compilations require a unique form of va_arg in order to access 16-byte      */
  38.     /* aligned vector data structures. __va_align__ is a special compile-time variable     */
  39.     /* that takes a type of expression as its argument and returns 16 if the type        */
  40.     /* is a vector type or a struct/class that contains a vector field.  It is 4 for     */
  41.     /* everything else.                                                                    */
  42. #if __VEC__
  43.     #define va_arg(ap, type) ((type *)(ap = (char *)(((unsigned long)ap+__va_align__(type)-1)&~(__va_align__(type)-1)) + sizeof(type)))[-1]
  44. #else
  45.     #define va_arg(ap, type) ((type *)(ap += sizeof (type)))[-1]
  46. #endif
  47.  
  48. #define va_end(ap)    /* do nothing */
  49.  
  50.  
  51. #endif
  52.